/*
 * GUIEmployee.java
 *
 * Created on 5. oktober 2006, 15:07
 *
 * Small changes due to architectual issues:
 * Object creation moved from GUI to Controller.
 * February 2010
 */

package GUILayer;

import javax.swing.JLabel;


import javax.swing.JTextPane;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.Box;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JButton;

import CtrLayer.SchemeCtr;
import javax.swing.JTextField;


/**
 * @author  kbh
 * @author  (FEN - small changes)
 * @author 	(RIJ - minor changes)
 */
public class GUINutritionRisk extends javax.swing.JFrame {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private SchemeCtr schemeCtr;
	private JTextField nameField;

	/** Creates new form GUIEmployee */
    public GUINutritionRisk( final JLabel mainFrameLabel, final DefaultTableModel model) {
		setTitle("Nutritional Risk Screening");
	getContentPane().setLayout(null);
	try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("b4/advancedgui/menu/resources/green_arrow_right.png")));
    } catch (Exception ex) {
        Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
       
    }
	schemeCtr=new SchemeCtr();
	setBounds(100, 100, 652, 683);
	Box horizontalBox = Box.createHorizontalBox();
	horizontalBox.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox.setBounds(6, 108, 135, 69);
	getContentPane().add(horizontalBox);
	
	JLabel lblNormalScore = new JLabel("Normal score = 0\r\n");
	horizontalBox.add(lblNormalScore);
	
	Box horizontalBox_1 = Box.createHorizontalBox();
	horizontalBox_1.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_1.setBounds(136, 108, 247, 69);
	getContentPane().add(horizontalBox_1);
	
	JTextPane txtpnNormalNutritionalStatus = new JTextPane();
	txtpnNormalNutritionalStatus.setEditable(false);
	horizontalBox_1.add(txtpnNormalNutritionalStatus);
	txtpnNormalNutritionalStatus.setText("Normal nutritional status\r\n");
	
	Box horizontalBox_2 = Box.createHorizontalBox();
	horizontalBox_2.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_2.setBounds(381, 108, 247, 69);
	getContentPane().add(horizontalBox_2);
	
	JTextPane txtpnNormalNutritionalRequirements = new JTextPane();
	txtpnNormalNutritionalRequirements.setEditable(false);
	horizontalBox_2.add(txtpnNormalNutritionalRequirements);
	txtpnNormalNutritionalRequirements.setText("Normal nutritional requirements");
	
	Box horizontalBox_3 = Box.createHorizontalBox();
	horizontalBox_3.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_3.setBounds(6, 176, 135, 84);
	getContentPane().add(horizontalBox_3);
	
	JLabel lblKj = new JLabel("Easy score =  1");
	horizontalBox_3.add(lblKj);
	
	Box horizontalBox_4 = Box.createHorizontalBox();
	horizontalBox_4.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_4.setBounds(282, 108, -135, 95);
	getContentPane().add(horizontalBox_4);
	
	Box horizontalBox_5 = Box.createHorizontalBox();
	horizontalBox_5.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_5.setBounds(136, 176, 247, 84);
	getContentPane().add(horizontalBox_5);
	
	JTextPane txtpnKjkljlk = new JTextPane();
	txtpnKjkljlk.setEditable(false);
	horizontalBox_5.add(txtpnKjkljlk);
	txtpnKjkljlk.setText("Wt loss>5% in 2 months or food intake below 50-75% of normal requirement in preceding week");
	
	Box horizontalBox_6 = Box.createHorizontalBox();
	horizontalBox_6.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_6.setBounds(381, 176, 247, 84);
	getContentPane().add(horizontalBox_6);
	
	JTextPane txtpnHipFractureChronic = new JTextPane();
	txtpnHipFractureChronic.setEditable(false);
	horizontalBox_6.add(txtpnHipFractureChronic);
	txtpnHipFractureChronic.setText("Hip fracture Chronic patiens, in particular with acute complications: cirhosis(11), COPD(12)");
	
	Box horizontalBox_7 = Box.createHorizontalBox();
	horizontalBox_7.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
	horizontalBox_7.setBounds(6, 258, 135, 120);
	getContentPane().add(horizontalBox_7);
	
	JLabel lblScore = new JLabel("Moderate score =  2");
	horizontalBox_7.add(lblScore);
	
	Box horizontalBox_8 = Box.createHorizontalBox();
	horizontalBox_8.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_8.setBounds(296, 319, -170, -120);
	getContentPane().add(horizontalBox_8);
	
	Box horizontalBox_9 = Box.createHorizontalBox();
	horizontalBox_9.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_9.setBounds(296, 319, -170, -120);
	getContentPane().add(horizontalBox_9);
	
	Box horizontalBox_10 = Box.createHorizontalBox();
	horizontalBox_10.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_10.setBounds(136, 258, 247, 120);
	getContentPane().add(horizontalBox_10);
	
	JTextPane txtpnWtLossIn = new JTextPane();
	txtpnWtLossIn.setEditable(false);
	horizontalBox_10.add(txtpnWtLossIn);
	txtpnWtLossIn.setText("Wt loss>5% in 2 months or BMI 18.5-20.5+impaired general condition or Food intake 25-50% of normal requirement in preceding week");
	
	Box horizontalBox_11 = Box.createHorizontalBox();
	horizontalBox_11.setBounds(463, 313, -166, -114);
	getContentPane().add(horizontalBox_11);
	
	Box horizontalBox_12 = Box.createHorizontalBox();
	horizontalBox_12.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_12.setBounds(477, 210, -108, 84);
	getContentPane().add(horizontalBox_12);
	
	Box horizontalBox_13 = Box.createHorizontalBox();
	horizontalBox_13.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_13.setBounds(381, 258, 247, 120);
	getContentPane().add(horizontalBox_13);
	
	JTextPane txtpnChronicHemodialysisDiabetes = new JTextPane();
	txtpnChronicHemodialysisDiabetes.setEditable(false);
	horizontalBox_13.add(txtpnChronicHemodialysisDiabetes);
	txtpnChronicHemodialysisDiabetes.setText("Chronic hemodialysis, diabetes, oncology Major abdominal surgery 13., 14. and 15.. \r\nStroke(16) Severe penumonia, hematologic malignacy");
	
	Box horizontalBox_14 = Box.createHorizontalBox();
	horizontalBox_14.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_14.setBounds(105, 438, -85, -95);
	getContentPane().add(horizontalBox_14);
	
	Box horizontalBox_15 = Box.createHorizontalBox();
	horizontalBox_15.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_15.setBounds(6, 377, 135, 120);
	getContentPane().add(horizontalBox_15);
	
	JLabel lblDifficultScore = new JLabel("Difficult score =  3");
	horizontalBox_15.add(lblDifficultScore);
	
	Box horizontalBox_16 = Box.createHorizontalBox();
	horizontalBox_16.setBounds(260, 438, -108, -87);
	getContentPane().add(horizontalBox_16);
	
	Box horizontalBox_17 = Box.createHorizontalBox();
	horizontalBox_17.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_17.setBounds(136, 377, 247, 120);
	getContentPane().add(horizontalBox_17);
	
	JTextPane txtpnWtLossIn_1 = new JTextPane();
	txtpnWtLossIn_1.setEditable(false);
	horizontalBox_17.add(txtpnWtLossIn_1);
	txtpnWtLossIn_1.setText("Wt loss>5% in 1 month(=>15% in 3 months(17)) or BMI  < 18.5+impaired general condition or Food intake 0-25% of normal requirement in preceding week");
	
	Box horizontalBox_18 = Box.createHorizontalBox();
	horizontalBox_18.setBounds(463, 448, -129, -104);
	getContentPane().add(horizontalBox_18);
	
	Box horizontalBox_19 = Box.createHorizontalBox();
	horizontalBox_19.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_19.setBounds(381, 377, 247, 120);
	getContentPane().add(horizontalBox_19);
	
	JTextPane txtpnHeadInjury = new JTextPane();
	horizontalBox_19.add(txtpnHeadInjury);
	txtpnHeadInjury.setEditable(false);
	txtpnHeadInjury.setText("Head injury 18. and 19. Bone marrow transplantation(20) Intensive care patients");
	
	JLabel lblImpairedNutritionalRisk = new JLabel("Impaired nutritional risk");
	lblImpairedNutritionalRisk.setFont(new Font("Tahoma", Font.BOLD, 11));
	lblImpairedNutritionalRisk.setBounds(136, 85, 161, 14);
	getContentPane().add(lblImpairedNutritionalRisk);
	
	JLabel lblSeverityOfDisease = new JLabel("Severity of disease");
	lblSeverityOfDisease.setFont(new Font("Tahoma", Font.BOLD, 11));
	lblSeverityOfDisease.setBounds(381, 85, 154, 14);
	getContentPane().add(lblSeverityOfDisease);
	
	Box horizontalBox_20 = Box.createHorizontalBox();
	horizontalBox_20.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_20.setBounds(6, 495, 135, 76);
	getContentPane().add(horizontalBox_20);
	
	Box horizontalBox_21 = Box.createHorizontalBox();
	horizontalBox_21.setBounds(296, 529, -170, -76);
	getContentPane().add(horizontalBox_21);
	
	Box horizontalBox_22 = Box.createHorizontalBox();
	horizontalBox_22.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_22.setBounds(136, 495, 247, 76);
	getContentPane().add(horizontalBox_22);
	
	final JComboBox nutrisk = new JComboBox();
	nutrisk.setFont(new Font("Tahoma", Font.PLAIN, 14));
	horizontalBox_22.add(nutrisk);
	nutrisk.setModel(new DefaultComboBoxModel(new String[] {"Choose score 0", "Choose score 1", "Choose score 2", "Choose score 3"}));
	
	Box horizontalBox_23 = Box.createHorizontalBox();
	horizontalBox_23.setBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
	horizontalBox_23.setBounds(381, 495, 247, 76);
	getContentPane().add(horizontalBox_23);
	
	final JComboBox disease = new JComboBox();
	disease.setFont(new Font("Tahoma", Font.PLAIN, 14));
	horizontalBox_23.add(disease);
	disease.setModel(new DefaultComboBoxModel(new String[] {"Choose score 0", "Choose score 1", "Choose score 2", "Choose score 3"}));
	
	JButton create_schema = new JButton("Create schema");
	create_schema.setBounds(498, 612, 130, 23);
	getContentPane().add(create_schema);
	
	JLabel lblNewLabel = new JLabel("Nutritional risk screening name:");
	lblNewLabel.setBounds(6, 30, 217, 14);
	getContentPane().add(lblNewLabel);
	
	nameField = new JTextField();
	nameField.setBounds(193, 19, 154, 36);
	getContentPane().add(nameField);
	nameField.setColumns(10);
	
	setVisible(true);
    
	create_schema.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			try{

				
				
				schemeCtr.createNutritionRiskScheme(nameField.getText(), nutrisk.getSelectedIndex(), disease.getSelectedIndex());
				
				mainFrameLabel.setForeground(new Color(0, 128, 0));
				mainFrameLabel
				.setText("Status: Scheme created successfuly");
				
				 String[] name={nameField.getText(),Integer.toString(nutrisk.getSelectedIndex()),Integer.toString(disease.getSelectedIndex())};
				 model.addRow(name);
				model.fireTableDataChanged();
			
			dispose();
			}
			
			catch(Exception ex)
			{
				System.out.println("Error while creating scale");
			}
		}


	});
    
    }
    


    


    }
